/*=========================================================================
The Impact of Denying a Wanted Abortion on Women and Children
Authors: Juliana Londoño-Vélez and Estefanía Saravia

Creation date: January 9th, 2024
--------------------------------------------------------------------------
Master.do
=========================================================================*/

*******************************************
*** SET MAIN ENVIRONMENT ***
*******************************************

	clear all
	set more off
	
	* Working directory
	display c(username) // To know your c(username)
	
		* Authors
		if 	"`c(username)'"=="esara" {
		global 	main "~\Dropbox\Tutelas y aborto\Submissions\QJE\4.Final\Replication"
		}
		
		* Replicator (insert your path)
		global 	main ""
			
		
	cd "${main}"
	
	* Style
	set scheme stcolor
	graph set window fontface "Palatino Linotype"

	* Max variables
	set maxvar 10000
	
	
	* Setting the ado path with required packages
	sysdir set PLUS "${main}/Do/ado"
	
	* Directories
	global code "${main}/Do"	
	global data "${main}/Data" // Contains simulated data (open to general public)
	global output "${main}/Output"
	
	
	*Install packages (You only need to run this part once!)
	ssc install egenmore, replace
	ssc install eventdd, replace
	ssc install matsort, replace
	ssc install workdays, replace
	ssc install matodd, replace
	
	cap ado uninstall ftools
	net install ftools, from("https://raw.githubusercontent.com/sergiocorreia/ftools/master/src/")

	cap ado uninstall reghdfe
	net install reghdfe, from("https://raw.githubusercontent.com/sergiocorreia/reghdfe/master/src/")
		
	ssc install ivreg2, replace
	
	cap ado uninstall ivreghdfe
	net install ivreghdfe, from(https://raw.githubusercontent.com/sergiocorreia/ivreghdfe/master/src/)

	ssc install ranktest, replace
	


*******************************************
*** CODE OUTPUT ***
*******************************************

	* Figures
	
		do "${code}/Output/Figure 1 - Female Judges are 20 p.p. Less Likely to Deny Women a Wanted Abortion.do" 
		do "${code}/Output/Figure 2 - Robustness Using Judge Stringency.do" 
		do "${code}/Output/Figure 3 - Impacts Across Time.do"  


	* Tables
	
		* Main
		do "${code}/Output/Table 1 - Summary Statistics.do"  
		do "${code}/Output/Table 2 - Baseline Characteristics of Women Filing Abortion Rights Claims.do"  
 		do "${code}/Output/Table 3 - Testing Balance.do" 
		do "${code}/Output/Table 4 - Test of Random Claim Assignment to Judges.do" 
		do "${code}/Output/Table 5 - Impacts of Denying a Wanted Abortion on Childbearing and Mortality.do"  
		do "${code}/Output/Table 6 - Impacts on Household Composition and Marital Status.do" 
		do "${code}/Output/Table 7 - Impacts on Womens Self-Reported Health.do" 
		do "${code}/Output/Table 8 - Impacts on Womens Educational Attainment and Labor-Force Participation.do" 
		do "${code}/Output/Table 9 - Impacts on Household Poverty and Welfare Assistance.do" 
		do "${code}/Output/Table 10 - The Impact of Being Denied a Wanted Abortion on a Womans Existing Children.do" 	
		
